﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Input;

namespace MediaPlayer.ViewModel
{
    class ButtonViewModel : ViewModelBase
	{
		#region Fields
		private ICommand		playButton;
		private ICommand		browseButton;
		private string			filename;
		#endregion

		#region Properties
		public ICommand PlayButton
		{
			get
			{
				if (this.playButton == null)
					this.playButton = new MyCommand(() => this.PlayPlayer());
				return this.playButton;
			}
		}

		public ICommand BrowseButton
		{
			get
			{
				if (this.browseButton == null)
					this.browseButton = new MyCommand(() => this.BrowseFile());
				return this.browseButton;
			}
		}


		#endregion

		public ButtonViewModel()
		{
			
		}

		public void PlayPlayer()
        {
			/*this.player.Source = new System.Uri(filename);
			this.player.LoadedBehavior = MediaState.Manual;
            this.player.Play();*/
        }

        private void BrowseFile()
        {
			Microsoft.Win32.OpenFileDialog	dlg = new Microsoft.Win32.OpenFileDialog();
			Nullable<bool>					result = dlg.ShowDialog();

			if (result == true)
			{
				this.filename = dlg.FileName;
			}
        }

		public void MediaOpened()
		{

		}

    }
}
